<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAgentTopUpOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('agent_top_up_orders', function (Blueprint $table) {
            $table->id();
            $table->char('order_id', 32)->unique()->comment('订单ID');
            $table->bigInteger('agent_id')->index()->comment('代理商 ID');
            $table->unsignedBigInteger('amount')->comment('充值金额 (单位分)');
            $table->json('reward_setting_snapshot')->nullable()->comment('充值结算时的充值奖励设置快照');
            $table->tinyInteger('status')->default(1)->comment('状态; 1:待支付 2:成功 3:取消 4:失败');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('agent_top_up_orders');
    }
}
